home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / src / sysfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-29  |  6.6 KB  |  260 lines

  1. /*
  2.    Copyright (C) 1995 Amdahl Corporation.
  3.  
  4. This file is part of XEmacs.
  5.  
  6. XEmacs is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation; either version 2, or (at your option) any
  9. later version.
  10.  
  11. XEmacs is distributed in the hope that it will be useful, but WITHOUT
  12. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14. for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with XEmacs; see the file COPYING.  If not, write to the Free
  18. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <errno.h>
  21. #include <sys/errno.h>          /* <errno.h> does not always imply this */
  22. /* Load sys/types.h if not already loaded.
  23.    In some systems loading it twice is suicidal.  */
  24. #ifndef makedev
  25. #include <sys/types.h>        /* some typedefs are used in sys/file.h */
  26. #endif
  27. #include <sys/file.h>
  28. #include <sys/stat.h>
  29. #include <sys/param.h>
  30.  
  31. #if NeXT
  32. /* what is needed from here?  Do others need it too? */
  33. # include <sys/fcntl.h>
  34. #endif /* NeXT */
  35.  
  36. #ifdef VMS
  37. #ifndef __GNUC__
  38. #include <file.h>
  39. #endif
  40. #include <rms.h>
  41. #include <rmsdef.h>
  42. #include <fab.h>
  43. #include <nam.h>
  44. #include <perror.h>
  45. #include <stddef.h>
  46. #endif
  47.  
  48. #ifdef MSDOS
  49. #include <dos.h>
  50. #include "msdos.h"
  51. #endif /* MSDOS */
  52.  
  53. #ifndef O_RDONLY
  54. #define O_RDONLY 0
  55. #endif
  56.  
  57. #ifndef O_WRONLY
  58. #define O_WRONLY 1
  59. #endif
  60.  
  61. #ifndef O_RDWR
  62. #define O_RDWR 2
  63. #endif
  64.  
  65. /* if system does not have symbolic links, it does not have lstat.
  66.    In that case, use ordinary stat instead.  */
  67.  
  68. #ifndef S_IFLNK
  69. #define lstat stat
  70. #endif
  71.  
  72. #ifndef S_IREAD
  73. #define S_IREAD S_IRUSR
  74. #define S_IWRITE S_IWUSR
  75. #define S_IEXEC S_IXUSR
  76. #endif
  77.  
  78. #if 0 /* This is unreliable, since GCC 2.5 always has S_ISREG in its
  79.      fixed headers but it does not always have mode_t.
  80.      It seems safer not to try to use mode_t ever.  */
  81. #if !defined(S_ISREG) || defined(NO_MODE_T)
  82. /* Doesn't have POSIX.1 stat stuff or doesn't have mode_t.  */
  83. #define mode_t unsigned short
  84. #endif
  85. #endif
  86.  
  87. #ifdef STAT_MACROS_BROKEN
  88. #undef S_ISBLK
  89. #undef S_ISCHR
  90. #undef S_ISDIR
  91. #undef S_ISFIFO
  92. #undef S_ISLNK
  93. #undef S_ISMPB
  94. #undef S_ISMPC
  95. #undef S_ISNWK
  96. #undef S_ISREG
  97. #undef S_ISSOCK
  98. #endif /* STAT_MACROS_BROKEN.  */
  99.  
  100. #if !defined(S_ISBLK) && defined(S_IFBLK)
  101. #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  102. #endif
  103. #if !defined(S_ISCHR) && defined(S_IFCHR)
  104. #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  105. #endif
  106. #if !defined(S_ISDIR) && defined(S_IFDIR)
  107. #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  108. #endif
  109. #if !defined(S_ISREG) && defined(S_IFREG)
  110. #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  111. #endif
  112. #if !defined(S_ISFIFO) && defined(S_IFIFO)
  113. #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  114. #endif
  115. #if !defined(S_ISLNK) && defined(S_IFLNK)
  116. #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  117. #endif
  118. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  119. #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  120. #endif
  121. #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
  122. #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
  123. #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
  124. #endif
  125. #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
  126. #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
  127. #endif
  128.  
  129. #if !defined (USG) && !defined (VMS)
  130. # define HAVE_FSYNC
  131. #endif
  132.  
  133. #ifndef MAXPATHLEN
  134. /* in 4.1, param.h fails to define this. */
  135. #define MAXPATHLEN 1024
  136. #endif /* not MAXPATHLEN */
  137.  
  138. #ifndef X_OK
  139. # define X_OK 01
  140. #endif
  141.  
  142. #ifndef FD_CLOEXEC
  143. # define FD_CLOEXEC 1
  144. #endif
  145.  
  146. /* encapsulations: file-information calls */
  147.  
  148. #ifdef ENCAPSULATE_ACCESS
  149. extern int sys_access (CONST char *path, int mode);
  150. #endif
  151. #if defined (ENCAPSULATE_ACCESS) && !defined (DONT_ENCAPSULATE)
  152. # undef access
  153. # define access sys_access
  154. #endif
  155. #if !defined (ENCAPSULATE_ACCESS) && defined (DONT_ENCAPSULATE)
  156. # define sys_access access
  157. #endif
  158.  
  159. #ifdef ENCAPSULATE_LSTAT
  160. extern int sys_lstat (CONST char *path, struct stat *buf);
  161. #endif
  162. #if defined (ENCAPSULATE_LSTAT) && !defined (DONT_ENCAPSULATE)
  163. # undef lstat
  164. # define lstat sys_lstat
  165. #endif
  166. #if !defined (ENCAPSULATE_LSTAT) && defined (DONT_ENCAPSULATE)
  167. # define sys_lstat lstat
  168. #endif
  169.  
  170. #ifdef ENCAPSULATE_READLINK
  171. extern int sys_readlink (CONST char *path, char *buf, int bufsiz);
  172. #endif
  173. #if defined (ENCAPSULATE_READLINK) && !defined (DONT_ENCAPSULATE)
  174. # undef readlink
  175. # define readlink sys_readlink
  176. #endif
  177. #if !defined (ENCAPSULATE_READLINK) && defined (DONT_ENCAPSULATE)
  178. # define sys_readlink readlink
  179. #endif
  180.  
  181. #ifdef ENCAPSULATE_STAT
  182. extern int sys_stat (CONST char *path, struct stat *buf);
  183. #endif
  184. #if defined (ENCAPSULATE_STAT) && !defined (DONT_ENCAPSULATE)
  185. # undef stat
  186. /* Need to use arguments to avoid messing with struct stat */
  187. # define stat(path, buf) sys_stat (path, buf)
  188. #endif
  189. #if !defined (ENCAPSULATE_STAT) && defined (DONT_ENCAPSULATE)
  190. # define sys_stat stat
  191. #endif
  192.  
  193. /* encapsulations: file-manipulation calls */
  194.  
  195. #ifdef ENCAPSULATE_CHMOD
  196. extern int sys_chmod (CONST char *path, int mode);
  197. #endif
  198. #if defined (ENCAPSULATE_CHMOD) && !defined (DONT_ENCAPSULATE)
  199. # undef chmod
  200. # define chmod sys_chmod
  201. #endif
  202. #if !defined (ENCAPSULATE_CHMOD) && defined (DONT_ENCAPSULATE)
  203. # define sys_chmod chmod
  204. #endif
  205.  
  206. #ifdef ENCAPSULATE_CREAT
  207. extern int sys_creat (CONST char *path, int mode);
  208. #endif
  209. #if defined (ENCAPSULATE_CREAT) && !defined (DONT_ENCAPSULATE)
  210. # undef creat
  211. # define creat sys_creat
  212. #endif
  213. #if !defined (ENCAPSULATE_CREAT) && defined (DONT_ENCAPSULATE)
  214. # define sys_creat creat
  215. #endif
  216.  
  217. #ifdef ENCAPSULATE_LINK
  218. extern int sys_link (CONST char *existing, CONST char *new);
  219. #endif
  220. #if defined (ENCAPSULATE_LINK) && !defined (DONT_ENCAPSULATE)
  221. # undef link
  222. # define link sys_link
  223. #endif
  224. #if !defined (ENCAPSULATE_LINK) && defined (DONT_ENCAPSULATE)
  225. # define sys_link link
  226. #endif
  227.  
  228. #ifdef ENCAPSULATE_RENAME
  229. extern int sys_rename (CONST char *old, CONST char *new);
  230. #endif
  231. #if defined (ENCAPSULATE_RENAME) && !defined (DONT_ENCAPSULATE)
  232. # undef rename
  233. # define rename sys_rename
  234. #endif
  235. #if !defined (ENCAPSULATE_RENAME) && defined (DONT_ENCAPSULATE)
  236. # define sys_rename rename
  237. #endif
  238.  
  239. #ifdef ENCAPSULATE_SYMLINK
  240. extern int sys_symlink (CONST char *name1, CONST char *name2);
  241. #endif
  242. #if defined (ENCAPSULATE_SYMLINK) && !defined (DONT_ENCAPSULATE)
  243. # undef symlink
  244. # define symlink sys_symlink
  245. #endif
  246. #if !defined (ENCAPSULATE_SYMLINK) && defined (DONT_ENCAPSULATE)
  247. # define sys_symlink symlink
  248. #endif
  249.  
  250. #ifdef ENCAPSULATE_UNLINK
  251. extern int sys_unlink (CONST char *path);
  252. #endif
  253. #if defined (ENCAPSULATE_UNLINK) && !defined (DONT_ENCAPSULATE)
  254. # undef unlink
  255. # define unlink sys_unlink
  256. #endif
  257. #if !defined (ENCAPSULATE_UNLINK) && defined (DONT_ENCAPSULATE)
  258. # define sys_unlink unlink
  259. #endif
  260.